﻿using DynamicControllersGeneration;

namespace ClientOverflow.ViewModels.Register
{
    /// <summary>
    /// MandatoryValidator is an implementation of IValidator. This validator checks if some string is filled with
    /// any value. The mandatory validator is passed to the dynamic controllers generation framework which calls
    /// the validator from the dynamic proxy.
    /// </summary>
    internal class MandatoryValidator : IValidator
    {
        private const string MANDATORY_FIELD_ERROR_MESSAGE = "This field is mandatory";

        public string Validate(object value)
        {
            if (string.IsNullOrWhiteSpace((string)value))
            {
                return MANDATORY_FIELD_ERROR_MESSAGE;
            }

            return null;
        }
    }
}